#region OpenNETCF Copyright Information
/*
Copyright (c) 2007 OpenNETCF Consulting, LLC

Permission is hereby granted, free of charge, to any person obtaining a copy of this software 
and associated documentation files (the "Software"), to deal in the Software without restriction,
including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, 
and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, 
subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial 
portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR 
PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE 
FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#endregion

using System;
using System.Collections.Generic;
using System.Text;
using OpenNETCF.WindowsMobile.Ink.Interfaces;
using System.Runtime.InteropServices;

namespace OpenNETCF.WindowsMobile.Ink
{
    
    /// <summary>
    /// Represents an object that is useful for annotation scenarios where users are not concerned with performing recognition on ink but instead are interested in the size, shape, color, and position of the ink.
    /// </summary>
    [Obsolete("Use Ink instead",true)]
    public class InkOverlay : Ink
    {
        /// <summary>
        /// Returns or sets the Ink object that is associated with an InkCollector object, an InkOverlay object, or a InkPicture control
        /// </summary>
        public IInkDisp Ink
        {
            get
            {
                return m_inkoverlay.Ink;
            }
        }
    }

    /// <summary>
    /// Represents an object that is useful for annotation scenarios where users are not concerned with performing recognition on ink but instead are interested in the size, shape, color, and position of the ink.
    /// </summary>
    public class Ink : IDisposable
    {
        internal IInkOverlay m_inkoverlay;

        public Ink()
        {
            m_inkoverlay = CreateInstance();
        }
        
        public void Dispose()
        {
            //Release the IInkOverlay COM object
            Marshal.ReleaseComObject(m_inkoverlay);
        }

        //TODO Wrap all properties of the IInkOverlay control instead of exposing the actual COM Object
        /// <summary>
        /// Gets the IInkOverlay COM object.
        /// </summary>
        public IInkOverlay IInkOverlay
        {
            get
            {
                return m_inkoverlay;
            }
        }

        /// <summary>
        /// Returns or sets the Ink object that is associated with an InkCollector object, an InkOverlay object, or a InkPicture control
        /// </summary>
        public IInkDisp InkDisp
        {
            get
            {
                return m_inkoverlay.Ink;
            }
        }

        /// <summary>
        /// Creates an instance of the IInkOverlay object
        /// </summary>
        /// <returns></returns>
        public static IInkOverlay CreateInstance()
        {
            Type t = Type.GetTypeFromCLSID(new Guid("65d00646-cde3-4a88-9163-6769f0f1a97d"));
            return (IInkOverlay)Activator.CreateInstance(t);
        }


        private ExtendedProperties m_inkproperties;
        /// <summary>
        /// Gets the extended properties associated with the ink overlay
        /// </summary>
        public ExtendedProperties ExtendedProperties
        {
            get
            {
                if (m_inkproperties == null)
                    m_inkproperties = new ExtendedProperties(m_inkoverlay.Ink.ExtendedProperties);
                return m_inkproperties;
            }
        }
    }
}
